package com.example.mysaat.service_menu_manual_test;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.mysaat.R;

public class ListViewAdapter extends BaseAdapter {
    private String [] datas = {"22","11","33","44","55","55"};
    private String [] results = {"not tested","pass","not tested","not tested","not tested","not tested"};
    private Context context;
    public ListViewAdapter(Context context){
        this.context = context;
    }

    public ListViewAdapter(String[] datas,String[] r,Context context){
        this.datas = datas;
        this.results = r;
        this.context = context;
    }
    @Override
    public int getCount() {
        return datas.length;
    }

    @Override
    public Object getItem(int i) {
        return datas[i];
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;
        if(view == null){
            view = LayoutInflater.from(context).inflate(R.layout.menu_test_result_list_view_item,viewGroup,false);
            viewHolder = new ViewHolder();
            viewHolder.name = view.findViewById(R.id.test_name);
            viewHolder.result = view.findViewById(R.id.test_result);
            view.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder) view.getTag();
        }
        viewHolder.name.setText(datas[i]);
        viewHolder.result.setText(results[i]);
        return view;
    }

    public  class ViewHolder{
            private TextView name,result;
        }
}
